/**
 * related to LogisticsList.ui
 * 
 * @Author : chenglm
 * @Timestamp : 2016-09-08
 */
var app = sm("do_App");
var page = sm("do_Page");
var deliveryUrl = require("url/delivery");
var qqHttp = require("helper/http");
var hashdata = mm("do_HashData");
var do_indexListView = ui("do_indexListView");
var hd = mm("do_HashData");

var firstChars = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
//andriod返回键
page.on("back", function() {
    app.closePage();
});

/* 头部 */
var headerAout = ui("do_ALayout_header");
var addheader = headerAout.add("header", "source://view/reuse/header.ui", 0, 0);
//左上角-返回
var headerLeft = ui(addheader+".headerLeft");
headerLeft.on("touch", function() {
    app.closePage()
});
var header = ui("header");
header.bindData(hashdata);
hashdata.addData({
    "labelTitle" : "选择物流公司"
})
header.refreshData();

//页面装载完成后，开始初始化工作
page.on("loaded", function() {
	loadData();
});

function loadData() {
	qqHttp.post(deliveryUrl.url.logistics.getLogistics, {}, function(data) {
		deviceone.print(JSON.stringify(data));
		hd.addData(data.logistics);
		do_indexListView.bindItems(hd, firstChars);
		do_indexListView.refreshItems();
	})
}

do_indexListView.on("touch",function(data, e){
    var cell = hd.getOne(data.groupID);
    var childData = cell[data.index];
    app.closePage({fromLogisticsList:1,name:childData.name});
});